package frontend.parser.node;

import frontend.parser.node.Node;
import frontend.parser.node.decl.Decl;
import frontend.parser.node.decl.FuncDef;
import frontend.parser.node.decl.MainFuncDef;

import java.util.ArrayList;

public class CompUnit extends Node {
    // 编译单元    CompUnit → {Decl} {FuncDef} MainFuncDef
    private final ArrayList<Decl> decls = new ArrayList<>();
    private final ArrayList<FuncDef> funcDefs = new ArrayList<>();
    private MainFuncDef mainFuncDef;

    public void addDecl(Decl decl) {
        super.add(decl);
        decls.add(decl);
    }

    public void addFuncDef(FuncDef funcDef) {
        super.add(funcDef);
        funcDefs.add(funcDef);
    }

    public void addMainFuncDef(MainFuncDef mainFuncDef) {
        super.add(mainFuncDef);
        this.mainFuncDef = mainFuncDef;
    }

    public ArrayList<Decl> getDecls() {
        return decls;
    }

    public ArrayList<FuncDef> getFuncDefs() {
        return funcDefs;
    }

    public MainFuncDef getMainFuncDef() {
        return mainFuncDef;
    }
}
